#!/bin/sh

# Entry point for Sigil on Unix systems.
# Adds linked Qt's lib directory to the LD_LIBRARY_PATH

QTLIB_DIR="${QT_LIBRARY_DIR}"
SIGIL_BIN_DIR="${CMAKE_INSTALL_FULL_LIBDIR}/sigil"

if [ -z "$LD_LIBRARY_PATH" ]; then
  LD_LIBRARY_PATH="$SIGIL_BIN_DIR:$QTLIB_DIR"
else
  LD_LIBRARY_PATH="$SIGIL_BIN_DIR:$QTLIB_DIR:$LD_LIBRARY_PATH"
fi

# Create an environment var for the Sigil share directory location.
if [ -z "$SIGIL_SHARE_PREFIX" ]; then
  SIGIL_SHARE_PREFIX="${SHARE_INSTALL_PREFIX}"
  export SIGIL_SHARE_PREFIX
fi

# Not really needed anymore but left in for fringe cases
#if [ -z "$SIGIL_EXTRA_ROOT" ]; then
#  SIGIL_EXTRA_ROOT="${SIGIL_SHARE_ROOT}"
#  export SIGIL_EXTRA_ROOT
#fi

export LD_LIBRARY_PATH

exec ${CMAKE_INSTALL_FULL_LIBDIR}/sigil/sigil "$@"

